<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>export method</Title>
			<Shortcut>export</Shortcut>
			<Description>扩展输出</Description>
			<Author>singba</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType> 
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>export</ID>
					<ToolTip>类名</ToolTip>
					<Default>ExportType</Default>
				</Literal>
				<Literal>
					<ID>type</ID>
					<ToolTip>输出类型</ToolTip>
					<Default>string</Default>
				</Literal>
				<Literal>
					<ID>id</ID>
					<ToolTip>标识名称</ToolTip>
					<Default>Name</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp">
<![CDATA[using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using AF.Core;

namespace AF
{
    public class $export$Exports
    {
        private static Lazy<Dictionary<string, $type$>> _Exports =
            new Lazy<Dictionary<string, $type$>>(() =>
            {
                var exports = ServiceLocator.Current.GetContainer()
                    .GetExports<$type$, I$export$Metadata>(
                    $export$Attribute.ExportContractName);
                Dictionary<string, $type$> values =
                    new Dictionary<string, $type$>();
                exports.ForEach(item =>
                {
                    values.Add(item.Metadata.$id$, item.Value);
                });
                return values;
            });

        public static $type$ Get(string name)
        {
            return _Exports.Value.GetDictionaryValue(name, null);
        }
    }

    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false), MetadataAttribute]
    public class $export$Attribute : ExportAttribute, I$export$Metadata
    {
        public const string ExportContractName = "$export$";

        public $export$Attribute(string name)
            : base(ExportContractName, typeof($type$))
        {
            $id$ = name;
        }

        public string $id$ { get; private set; }
    }

    public interface I$export$Metadata
    {
        string $id$ { get; }
    }
}$end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
